/**
 * 
 */
package post.graduate.go.ready.experiment.nekohtml;

import org.cyberneko.html.parsers.DOMParser;
//import org.w3c.dom.Document;
import org.w3c.dom.Node;

/**
 * @author lihb
 * 
 */
public class NekohtmlTest {

	/**
	 * @param args
	 */
	public static void main(String[] argv) throws Exception {
		DOMParser parser = new DOMParser();
		//for (int i = 0; i < argv.length; i++) {
			//parser.parse(argv[i]);
		parser.setProperty("http://cyberneko.org/html/properties/default-encoding","GBK");
		parser.setFeature("http://xml.org/sax/features/namespaces", false); 
		//parser.parse("a.html");
		print(parser.getDocument(), "");
		//}
	}

	public static void print(Node node, String indent) {
		// System.out.println(indent+node.getClass().getName());
		if (node.getNodeValue() != null) {
			if ("".equals(node.getNodeValue().trim())) {
			} else {
				System.out.print(indent);
				System.out.println(node.getNodeValue());
			}
		}

		Node child = node.getFirstChild();
		while (child != null) {
			print(child, indent + " ");
			child = child.getNextSibling();
		}
	}

}
